package com.zc.framework.web.filter;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created by zc on 2016/9/2.
 */
public class AppInitFilter implements Filter {

    private static Logger logger = LogManager.getLogger(AppInitFilter.class);

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest http_request = (HttpServletRequest) servletRequest;
        String path = http_request.getContextPath();
        http_request.setAttribute("rootPath",path);
//        logger.info("rootPath: " + path);
        filterChain.doFilter(http_request,servletResponse);
    }

    @Override
    public void destroy() {

    }
}
